package com.shujia.mr.DianXin3;

import com.shujia.mr.DianXin2.DianXinDemo2;
import com.shujia.mr.DianXin2.DianXinMapper2;
import com.shujia.mr.DianXin2.DianXinReducer2;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class DianXinDemo3 {
    public static void main(String[] args) throws Exception{
//        Configuration conf = new Configuration();
//        Job job = Job.getInstance(conf);
//        job.setJobName("");
        //创建hadoop配置文件对象
        Configuration conf = new Configuration();
        //创建作业对象
        Job job = Job.getInstance(conf);
        //设置任务对象
        job.setJobName("个人在城市停留平均时间测试程序");

        //设置主类名
        job.setJarByClass(DianXinDemo3.class);

        //设置map类
        job.setMapperClass(DianXinMapper3.class);

        //设置reduce类
        job.setReducerClass(DianXinReducer3.class);

        //设置map任务输出的键和值类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Text.class);
        //设置reduce任务输出的键和值类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);

        //设置文件输入的路径
        FileInputFormat.addInputPath(job,new Path(args[0]));
        //文件输出路径
        FileOutputFormat.setOutputPath(job,new Path(args[1]));
        boolean flag = job.waitForCompletion(true);
        if (flag) {
            System.out.println("===========个人在城市停留平均时间测试程序运行成功===============");
        }else {
            System.out.println("===========个人在城市停留平均时间测试程序运行失败============");
        }



    }
}
